package jh.slm.calculations;

public class Resampling2000 {

	public Object Input;
	public Object Output;
	Object state;
	int[] coef;
	int length;

	public Resampling2000(int length){
		this.length = length;
		int up = 1;
		int down = 24;
		Output = Allocator.Allocate(length * up / down);
		coef = Coef();
		state = Resampling.Init(down, up, coef);
	}

	public void Free(){
		Allocator.Free(Output);
	}
	
	public void Connect(Object input) {
		Input = input;
	}

	public void Compute() {
		Resampling.Resample(length, Input, Output, state);
	}

	public int[] GetOutput()
	{
		return Allocator.DeRefInt(Output);
	}

	private int[] Coef(){
		return new int[]{
				-37108,
				-9962,
				-10786,
				-11257,
				-11276,
				-10745,
				-9556,
				-7606,
				-4786,
				-997,
				3859,
				9866,
				17101,
				25623,
				35479,
				46691,
				59264,
				73169,
				88351,
				104713,
				122134,
				140454,
				159492,
				179035,
				198833,
				218588,
				237963,
				256613,
				274215,
				290426,
				304693,
				316794,
				326236,
				332653,
				335677,
				334953,
				330175,
				321063,
				307404,
				289025,
				265835,
				237798,
				204972,
				167485,
				125570,
				79533,
				29784,
				-23189,
				-78799,
				-136381,
				-195178,
				-254370,
				-313069,
				-370348,
				-425225,
				-476692,
				-523730,
				-565352,
				-600570,
				-628415,
				-648050,
				-658645,
				-659510,
				-650066,
				-629853,
				-598580,
				-556099,
				-502457,
				-437871,
				-362766,
				-277748,
				-183635,
				-81426,
				27674,
				142294,
				260881,
				381744,
				503052,
				622875,
				739191,
				849935,
				953015,
				1046368,
				1127962,
				1195861,
				1248245,
				1283470,
				1300067,
				1296802,
				1272722,
				1227135,
				1159690,
				1070368,
				959503,
				827812,
				676371,
				506650,
				320476,
				120050,
				-92099,
				-313112,
				-539858,
				-768948,
				-996801,
				-1219668,
				-1433712,
				-1635045,
				-1819809,
				-1984217,
				-2124640,
				-2237656,
				-2320138,
				-2369291,
				-2382735,
				-2358547,
				-2295337,
				-2192257,
				-2049079,
				-1866211,
				-1644707,
				-1386304,
				-1093413,
				-769104,
				-417107,
				-41759,
				352010,
				758762,
				1172576,
				1587158,
				1995887,
				2391938,
				2768353,
				3118167,
				3434491,
				3710652,
				3940281,
				4117449,
				4236756,
				4293459,
				4283556,
				4203908,
				4052292,
				3827507,
				3529423,
				3159044,
				2718524,
				2211222,
				1641674,
				1015603,
				339881,
				-377512,
				-1127563,
				-1900287,
				-2684848,
				-3469647,
				-4242475,
				-4990628,
				-5701081,
				-6360625,
				-6956063,
				-7474355,
				-7902822,
				-8229300,
				-8442336,
				-8531343,
				-8486781,
				-8300296,
				-7964881,
				-7474992,
				-6826680,
				-6017665,
				-5047442,
				-3917313,
				-2630441,
				-1191844,
				391593,
				2111179,
				3956455,
				5915287,
				7973966,
				10117342,
				12328955,
				14591223,
				16885596,
				19192784,
				21492932,
				23765873,
				25991318,
				28149117,
				30219460,
				32183133,
				34021713,
				35717808,
				37255242,
				38619262,
				39796698,
				40776131,
				41548023,
				42104842,
				42441129,
				42553594,
				42441129,
				42104842,
				41548023,
				40776131,
				39796698,
				38619262,
				37255242,
				35717808,
				34021713,
				32183133,
				30219460,
				28149117,
				25991318,
				23765873,
				21492932,
				19192784,
				16885596,
				14591223,
				12328955,
				10117342,
				7973966,
				5915287,
				3956455,
				2111179,
				391593,
				-1191844,
				-2630441,
				-3917313,
				-5047442,
				-6017665,
				-6826680,
				-7474992,
				-7964881,
				-8300296,
				-8486781,
				-8531343,
				-8442336,
				-8229300,
				-7902822,
				-7474355,
				-6956063,
				-6360625,
				-5701081,
				-4990628,
				-4242475,
				-3469647,
				-2684848,
				-1900287,
				-1127563,
				-377512,
				339881,
				1015603,
				1641674,
				2211222,
				2718524,
				3159044,
				3529423,
				3827507,
				4052292,
				4203908,
				4283556,
				4293459,
				4236756,
				4117449,
				3940281,
				3710652,
				3434491,
				3118167,
				2768353,
				2391938,
				1995887,
				1587158,
				1172576,
				758762,
				352010,
				-41759,
				-417107,
				-769104,
				-1093413,
				-1386304,
				-1644707,
				-1866211,
				-2049079,
				-2192257,
				-2295337,
				-2358547,
				-2382735,
				-2369291,
				-2320138,
				-2237656,
				-2124640,
				-1984217,
				-1819809,
				-1635045,
				-1433712,
				-1219668,
				-996801,
				-768948,
				-539858,
				-313112,
				-92099,
				120050,
				320476,
				506650,
				676371,
				827812,
				959503,
				1070368,
				1159690,
				1227135,
				1272722,
				1296802,
				1300067,
				1283470,
				1248245,
				1195861,
				1127962,
				1046368,
				953015,
				849935,
				739191,
				622875,
				503052,
				381744,
				260881,
				142294,
				27674,
				-81426,
				-183635,
				-277748,
				-362766,
				-437871,
				-502457,
				-556099,
				-598580,
				-629853,
				-650066,
				-659510,
				-658645,
				-648050,
				-628415,
				-600570,
				-565352,
				-523730,
				-476692,
				-425225,
				-370348,
				-313069,
				-254370,
				-195178,
				-136381,
				-78799,
				-23189,
				29784,
				79533,
				125570,
				167485,
				204972,
				237798,
				265835,
				289025,
				307404,
				321063,
				330175,
				334953,
				335677,
				332653,
				326236,
				316794,
				304693,
				290426,
				274215,
				256613,
				237963,
				218588,
				198833,
				179035,
				159492,
				140454,
				122134,
				104713,
				88351,
				73169,
				59264,
				46691,
				35479,
				25623,
				17101,
				9866,
				3859,
				-997,
				-4786,
				-7606,
				-9556,
				-10745,
				-11276,
				-11257,
				-10786,
				-9962,
				-37108
		};
	}

}
